package bookez.view.bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import bookez.model.businessobject.Route;
import bookez.model.service.RouteService;

@ManagedBean
@SessionScoped
public class RouteBean extends BaseBean {
		
	public final static String CREATE_SUCCEEDED = "bookez.view.bean.RouteBean.CREATE_SUCCEEDED";
	public final static String CANNOT_CREATE	= "bookez.view.bean.RouteBean.CANNOT_CREATE";
	public final static String ROUTE_EXISTING 	= "bookez.view.bean.RouteBean.ROUTE_EXISTING";
	
	/**
	 * An utility method to create an Route object from
	 * properties of a RouteBean object.
	 * @param bean
	 * @return
	 */
	public static Route createRoute( RouteBean bean ) {
		Route route  = new Route();
		route.setFromCity( bean.getFromCity() );
		route.setToCity( bean.getToCity() );
		return route;
	}//end method createRoute
	
	
	public String getFromCity() { return fromCity; }
	public void setFromCity(String fromCity) { this.fromCity = fromCity; }

	
	public String getToCity() {	return toCity; }
	public void setToCity(String toCity) { this.toCity = toCity; }
	
	public RouteService getService() { return this.routeService; }
	public void setService( RouteService value ) { this.routeService = value; }
	
	private String fromCity;
	private String toCity;
	
	@ManagedProperty ( name = "service", value = "#{routeService}" )
	private RouteService routeService;
	
	private static final long serialVersionUID = 5069300614032020737L;
}//end class RouteBean
